<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="bp" value="${pageContext.request.contextPath}"></c:set>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<jsp:useBean id="timestamp" class="java.util.Date"/>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>用户管理</title>
    <!-- Bootstrap Styles-->
    <link href="${bp}/static/assets/css/bootstrap.css" rel="stylesheet" />
    <!-- FontAwesome Styles-->
    <link href="${bp}/static/assets/css/font-awesome.css" rel="stylesheet" />
    <!-- Morris Chart Styles-->
    <link href="${bp}/static/assets/js/morris/morris-0.4.3.min.css" rel="stylesheet" />
    <!-- Custom Styles-->
    <link href="${bp}/static/assets/css/custom-styles.css" rel="stylesheet" />
    <!-- Google Fonts-->
    <link href='https://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css' />
    <link rel="stylesheet" href="${bp}/static/assets/js/Lightweight-Chart/cssCharts.css">
</head>

<body>
<div id="wrapper">
    <nav class="navbar navbar-default top-navbar" role="navigation">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".sidebar-collapse">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="${bp}/user/index">
                <strong>蓝天洗衣管理系统</strong>
            </a>

            <div id="sideNav" href="">
                <i class="fa fa-caret-right"></i>
            </div>
        </div>

        <ul class="nav navbar-top-links navbar-right">
            <!-- /.dropdown -->
            <li class="dropdown">
                <a class="dropdown-toggle" data-toggle="dropdown" href="#" aria-expanded="false">
                    <i class="fa fa-bell fa-fw"></i>

                    <c:if test="${orderconet > 0}">
                        <span class="badge" style="color: red">${orderconet}</span>
                    </c:if>
                    <i class="fa fa-caret-down"></i>
                </a>
                <ul class="dropdown-menu dropdown-alerts">
                    <li>
                        <a href="${bp}/order/orderAll">
                            <c:if test="${orderconet > 0}">
                                <i class="fa fa-comment fa-fw"></i>${orderconet}个订单等待您处理
                            </c:if>
                        </a>
                    </li>
                </ul>
                <!-- /.dropdown-alerts -->
            </li>
            <!-- /.dropdown -->
            <li class="dropdown">
                <a class="dropdown-toggle" data-toggle="dropdown" href="#" aria-expanded="false">
                    <i class="fa fa-user fa-fw"></i>
                    <i class="fa fa-caret-down"></i>
                </a>
                <ul class="dropdown-menu dropdown-user">
                    <li>
                        <a href="${bp}/user/userInfo">
                            <i class="fa fa-user fa-fw"></i> 用户信息</a>
                    </li>
                    <li class="divider"></li>
                    <li>
                        <a href="${bp}/user/loginOut">
                            <i class="fa fa-sign-out fa-fw"></i> 退出系统</a>
                    </li>
                </ul>
                <!-- /.dropdown-user -->
            </li>
            <!-- /.dropdown -->
        </ul>
    </nav>
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".sidebar-collapse">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="index.html">
                <strong>蓝天洗衣管理系统</strong>
            </a>

            <div id="sideNav" href="">
                <i class="fa fa-caret-right"></i>
            </div>
        </div>

        <ul class="nav navbar-top-links navbar-right">
            <!-- /.dropdown -->
            <li class="dropdown">
                <a class="dropdown-toggle" data-toggle="dropdown" href="#" aria-expanded="false">
                    <i class="fa fa-bell fa-fw"></i>
                    <i class="fa fa-caret-down"></i>
                </a>
                <ul class="dropdown-menu dropdown-alerts">
                    <li>
                        <a href="#">
                            <div>
                                <i class="fa fa-comment fa-fw"></i> New Comment
                                <span class="pull-right text-muted small">4 min</span>
                            </div>
                        </a>
                    </li>
                    <li class="divider"></li>
                    <li>
                        <a href="#">
                            <div>
                                <i class="fa fa-twitter fa-fw"></i> 3 New Followers
                                <span class="pull-right text-muted small">12 min</span>
                            </div>
                        </a>
                    </li>
                    <li class="divider"></li>
                    <li>
                        <a href="#">
                            <div>
                                <i class="fa fa-envelope fa-fw"></i> Message Sent
                                <span class="pull-right text-muted small">4 min</span>
                            </div>
                        </a>
                    </li>
                    <li class="divider"></li>
                    <li>
                        <a href="#">
                            <div>
                                <i class="fa fa-tasks fa-fw"></i> New Task
                                <span class="pull-right text-muted small">4 min</span>
                            </div>
                        </a>
                    </li>
                    <li class="divider"></li>
                    <li>
                        <a href="#">
                            <div>
                                <i class="fa fa-upload fa-fw"></i> Server Rebooted
                                <span class="pull-right text-muted small">4 min</span>
                            </div>
                        </a>
                    </li>
                    <li class="divider"></li>
                    <li>
                        <a class="text-center" href="#">
                            <strong>See All Alerts</strong>
                            <i class="fa fa-angle-right"></i>
                        </a>
                    </li>
                </ul>
                <!-- /.dropdown-alerts -->
            </li>
            <!-- /.dropdown -->
            <li class="dropdown">
                <a class="dropdown-toggle" data-toggle="dropdown" href="#" aria-expanded="false">
                    <i class="fa fa-user fa-fw"></i>
                    <i class="fa fa-caret-down"></i>
                </a>
                <ul class="dropdown-menu dropdown-user">

                    <li class="divider"></li>
                    <li>
                        <a href="${bp}/user/loginOut">
                            <i class="fa fa-sign-out fa-fw"></i> 退出系统</a>
                    </li>
                </ul>
                <!-- /.dropdown-user -->
            </li>
            <!-- /.dropdown -->
        </ul>
    </nav>
    <!--/. NAV TOP  -->
    <nav class="navbar-default navbar-side" role="navigation">
        <div class="sidebar-collapse">
            <ul class="nav" id="main-menu">
                <li>
                    <a  href="${bp}/user/index">
                        <i class="fa fa-dashboard"></i>首页</a>
                </li>
                <li>
                    <a class="active-menu" href="${bp}/user/user?page=1">
                        <i class="fa fa-dashboard"></i>用户管理</a>
                </li>
                <li>
                    <a href="${bp}/order/orderAll">
                        <i class="fa fa-qrcode"></i>订单管理</a>
                </li>
                <li>
                    <a href="${bp}/equipment/equipment?page=1">
                        <i class="fa fa-desktop"></i>消耗品管理</a>
                </li>
                <li>
                    <a href="${bp}/log/log">
                        <i class="fa fa-bar-chart-o"></i>日志记录</a>
                </li>
                <li>
                    <a href="${bp}/work/work?page=1">
                        <i class="fa fa-table"></i>职员管理</a>
                </li>
            </ul>

        </div>

    </nav>
    <!-- /. NAV SIDE  -->
    <!-- 内容块 -->
    <div id="page-wrapper">
        <!-- header -->
        <div class="header">
            <h1 class="page-header">
                用户管理
                <small>欢迎您，${sessionScope.user.name}</small>
            </h1>
            <!-- 模拟路由地址 -->
            <ol class="breadcrumb">
                <li>
                    <a href="user.html">用户管理</a>
                </li>
                <!-- <li>
                    <a href="#">Dashboard</a>
                </li>
                <li class="active">Data</li> -->
            </ol>

        </div>
        <div id="page-inner">

            <div class="row">
                <div class="col-md-12 col-sm-12 col-xs-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">

                        </div>
                        <div class="panel-body">
                            <div class="table-responsive">



                                <table id="tab" class="table table-striped table-bordered table-hover">
                                    <thead>
                                    <tr >
                                        <th>序号</th>
                                        <th>名字</th>
                                        <th>用户名</th>
                                        <th>密码</th>
                                        <th>地址</th>
                                        <th>余额</th>
                                        <th>手机号</th>
                                        <th>会员</th>
                                        <th>注册时间</th>
                                        <th>操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>

                                    <c:forEach items="${listuser.list}" var="keyword" varStatus="id">
                                        <tr>

                                            <td>${id.index+1}</td>
                                            <td>${keyword.name}</td>
                                            <td>${keyword.username}</td>
                                            <td>${keyword.password}</td>
                                            <td>${keyword.addr}</td>
                                            <td>${keyword.mony}</td>
                                            <td>${keyword.phone}</td>
                                            <td>
                                                <c:if test="${(keyword.leiji > 0)   &&  (keyword.leiji < 200)}">VIP1</c:if>
                                                <c:if test="${(keyword.leiji > 100) &&  (keyword.leiji < 300)}">VIP2</c:if>
                                                <c:if test="${(keyword.leiji > 300) &&  (keyword.leiji < 700)}">VIP3</c:if>
                                                <c:if test="${(keyword.leiji > 700) &&  (keyword.leiji < 1000)}">VIP4</c:if>
                                            </td>
                                            <td><jsp:setProperty name="timestamp" property="time" value="${keyword.saveDate}"/>
                                                <fmt:formatDate value="${timestamp}" pattern="yyyy/MM/dd/ HH:mm:ss"/></td>


                                            <td>

                                                <div class="row">
                                                    <div class="col-md-6">
                                                       <button type="button" class="btn btn-success btn-lg" data-toggle="modal" data-target="#rechange${keyword.id}">
                                                        充值
                                                    </button>
                                                    </div>
                                                </div>
                                                <div class="row">
                                                    <div class="col-md-12">
                                                        <!-- Modal -->
                                                        <div class="modal fade" id="rechange${keyword.id}" tabindex="-1" role="dialog" aria-labelledby="">
                                                            <div class="modal-dialog" role="document">
                                                                <div class="modal-content">
                                                                    <div class="modal-header">
                                                                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                                                            <span aria-hidden="true">&times;</span>
                                                                        </button>
                                                                        <h4 class="modal-title" id=""><h1>会员卡充值</h1></h4>
                                                                    </div>
                                                                    <div class="modal-body">

                                                                        <input id="chognzhi${keyword.id}" type="text" value="" placeholder="请输入充值金额">
                                                                    </div>
                                                                    <div class="modal-footer">
                                                                        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                                                                        <button type="button" onclick="add(${keyword.id})" class="btn btn-success">充值</button>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </td>
                                        </tr>
                                    </c:forEach>
                                    </tbody>
                                </table>
                                <ul class="pagination">
                                    <li><a href="#">&laquo;</a></li>
                                    <li><a href="${bp}/user/user?page=1">1</a></li>
                                    <li><a href="${bp}/user/user?page=2">2</a></li>
                                    <li><a href="${bp}/user/user?page=3">3</a></li>
                                    <li><a href="${bp}/user/user?page=4">4</a></li>
                                    <li><a href="${bp}/user/user?page=5">5</a></li>
                                    <li><a href="#">&raquo;</a></li>
                                </ul>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
            <!-- /. ROW  -->
        </div>
        <!-- /. PAGE INNER  -->
    </div>
    <!-- /. PAGE WRAPPER  -->
</div>
<!-- /. WRAPPER  -->
<!-- JS Scripts-->
<!-- jQuery Js -->
<script src="${bp}/static/assets/js/jquery-3.2.1.min.js"></script>
<!-- Bootstrap Js -->
<script src="${bp}/static/assets/js/bootstrap.min.js"></script>

<!-- Metis Menu Js -->
<script src="${bp}/static/assets/js/jquery.metisMenu.js"></script>
<!-- Morris Chart Js -->
<script src="${bp}/static/assets/js/morris/raphael-2.1.0.min.js"></script>
<script src="${bp}/static/assets/js/morris/morris.js"></script>


<script src="${bp}/static/assets/js/easypiechart.js"></script>
<script src="${bp}/static/assets/js/easypiechart-data.js"></script>

<script src="${bp}/static/assets/js/Lightweight-Chart/jquery.chart.js"></script>

<!-- Custom Js -->
<script src="${bp}/static/assets/js/custom-scripts.js"></script>

<script type="text/javascript">


    function add() {
        var chongzhi = $("#chognzhi"+obj).val();
        $.ajax({
            type:"GET",
            url:"${bp}/vip/chongzhi",
            data:{"id":obj,"nmeber":chongzhi},
            success : function (msg) {
                if(msg == 1){
                    alert("充值成功")
                    window.location.reload()
                }
                if(msg == 2){
                    alert("充值失败")
                    window.location.reload()
                }
            }
        })
    }


    function select() {
        var chongzhi = $("#aaa").val();
        $.ajax({
            type:"GET",
            url:"${bp}/user/selectUsername",
            data:{"selectUsername":chongzhi},
            success : function (msg) {
              //  [{"username":"wangcc","password":"1234567","addr":"太原市小店区长治路120号001","phone":"158584154","saveDate":"1524109153603","role":"1","name":"段誉","id":1}]
               /// var date = formatDateTime(msg[i].saveDate)

                console.log(msg)
                console.log(msg.id)
                if (msg == null) {
                    alert("没有该用户")
                } else {
                        // var leiji = msg[i].lei;
                        // var huiy
                        // if (leiji > 0 && leiji < 100) {
                        //     huiy = "VIP1"
                        // } else if (leiji > 100 && leiji < 300) {
                        //     huiy = "VIP2"
                        // } else if (leiji > 300 && leiji < 700) {
                        //     huiy = "VIP3"
                        // } else if (leiji > 700 && leiji < 1000) {
                        //     huiy = "VIP4"
                        // } else {
                        //     huiy = "VIP1"
                        // }

                        // // console.log(name)
                        // var username = msg[i].username
                        // // console.log(username)
                        // var password = msg[i].password
                        // // console.log(password)
                        // var addr = msg[i].addr
                        // // console.log(addr)
                        // var mony = msg[i].mony
                        // // console.log(mony)
                        // var phone = msg[i].phone
                        // // console.log(password)
                        // var saveDate = msg[i].saveDate
                        // // console.log()
                        // // var id = i+1



                        // var md = " <tr>\n" +
                        //     "                     <th>" +id+ "</th>\n" +
                        //     "                     <th>" +name+ "</th>\n" +
                        //     "                     <th>" +username+ "</th>\n" +
                        //     "                     <th>"  +password+"</th>\n" +
                        //     "                     <th>" +addr +"</th>\n" +
                        //     "                     <th>" +mony+"</th>\n" +
                        //     "                     <th>" +phone+ "</th>\n" +
                        //     "                     <th>" +huiy+ "</th>\n" +
                        //     "                     <th>" +saveDate+ "</th>\n" +
                        //     "                     <th><button>充值</button></th>\n" +
                        //     "                     </tr>"
                        //
                        // $("#tab").html(md)


                }
            }
        })
    }


    function formatDateTime(inputTime) {
        var date = new Date(inputTime);
        var y = date.getFullYear();
        var m = date.getMonth() + 1;
        m = m < 10 ? ('0' + m) : m;
        var d = date.getDate();
        d = d < 10 ? ('0' + d) : d;
        var h = date.getHours();
        h = h < 10 ? ('0' + h) : h;
        var minute = date.getMinutes();
        var second = date.getSeconds();
        minute = minute < 10 ? ('0' + minute) : minute;
        second = second < 10 ? ('0' + second) : second;
        return y + '-' + m + '-' + d+' '+h+':'+minute+':'+second;
    };



</script>

</body>

</html>